<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
  	<title>餐厅管理</title>
  	<%@ include file="../include/jsCss.jsp" %> 
  	<script>
  		//全选
	function checkedAll(t) { 
		$("input[name='sellCheckBox']").each(function(i,item){
			 item.checked = t.checked;
		}); 
	} 
  	//审核通过和不通过
	function auditRestaurant(status) {
		var restaurantIds = ""; 
		$("input[name='sellCheckBox']").each(function(i,item){
			 if (item.checked == true) {
				 restaurantIds += item.value + ",";
			 }
		});
		 
		if (restaurantIds == "") {
			alert("请选择要审核的餐厅!");
			return;
		}
		restaurantIds = restaurantIds.substring(0, restaurantIds.length-1);
		var dt = new Date();
		$.ajax( {
			type : "POST",
			url : "restaurant!audit.html",
			data : "restaurantIds="+restaurantIds+"&status="+status+"&date=" + dt,
			success : function(data) {
				if ($.trim(data) == 0) {
					if (status == 1) { 
						alert('审核通过成功!');
					}
					if (status == 2) {
						alert('审核不通过成功');
					}
					document.location.reload();
				} else {
					alert('操作失败!');
				}
			}
		}); 
	}
	
	//作废和取消作废
	function invalidRestaurant(status) {
		var restaurantIds = ""; 
		$("input[name='sellCheckBox']").each(function(i,item){
			 if (item.checked == true) {
				 restaurantIds += item.value + ",";
			 }
		});
		 
		if (restaurantIds == "") {
			if (status == 3) {
				alert("请选择要作废的餐厅!");
			}
			if (stauts == 1) {
				alert("请选择要取消作废的餐厅!");
			}
			return;
		}
		restaurantIds = restaurantIds.substring(0, restaurantIds.length-1);
		var dt = new Date();
		$.ajax( {
			type : "POST",
			url : "restaurant!invalid.html",
			data : "restaurantIds="+restaurantIds+"&status="+status+"&date=" + dt,
			success : function(data) {
				if ($.trim(data) == 0) {
					if (status == 3) { 
						alert('作废成功!');
					}
					if (status == 1) {
						alert('取消作废成功');
					}
					document.location.reload();
				} else {
					alert('操作失败!');
				}
			}
		}); 
	}
	
	//推荐和取消推荐
	function recommendRestaurant(isRecommend) {
		var restaurantIds = ""; 
		$("input[name='sellCheckBox']").each(function(i,item){
			 if (item.checked == true) {
				 restaurantIds += item.value + ",";
			 }
		});
		 
		if (restaurantIds == "") {
			if (isRecommend == true) {
				alert("请选择要推荐的餐厅!");
			}
			if (isRecommend == false) {
				alert("请选择要取消推荐的餐厅!");
			}
			return;
		}
		restaurantIds = restaurantIds.substring(0, restaurantIds.length-1);
		var dt = new Date();
		$.ajax( {
			type : "POST",
			url : "restaurant!recommend.html",
			data : "restaurantIds="+restaurantIds+"&isRecommend="+isRecommend+"&date=" + dt,
			success : function(data) {
				if ($.trim(data) == 0) {
					if (isRecommend == true) { 
						alert('推荐成功!');
					}
					if (isRecommend == false) {
						alert('取消推荐成功');
					}
					document.location.reload();
				} else {
					alert('操作失败!');
				}
			}
		}); 
	}
  	</script>
  </head>
  
  <body>
  	<form action="restaurant!restaurantList.html" method="post" id="frmSubmitSelect">
		餐厅管理
		<hr/>
		<table width="100%">
			<tr>
				<td>餐厅名称</td>
				<td><input type="text" name="name" /></td>  
				<td><input type="button" value="搜索" id="" onclick="javascript:onsubmitSelect();"/></td>
				<td style="text-align: right;">
					<a href="javascript:;" onclick="auditRestaurant(1)">审核通过</a>	|
					<a href="javascript:;" onclick="auditRestaurant(2)">审核不通过</a>|
					<a href="javascript:;" onclick="recommendRestaurant(true)">推荐餐厅</a>|
					<a href="javascript:;" onclick="recommendRestaurant(false);">取消推荐</a>|
					<a href="javascript:;" onclick="invalidRestaurant(3);">作废餐厅</a>|
					<a href="javascript:;" onclick="invalidRestaurant(1);">取消作废</a>
				</td>
			</tr>
		</table>

		<table width="130%" border="1">
			<tr>
				<td rowspan="1" ><input type="checkbox" name="sellCheckBoxAll" onclick="checkedAll(this)"/></td>
				<td>编号</td>
				<td>饭店名称</td> 
				<td>餐厅地址</td>
				<td>餐厅菜系</td>
				<td>营业时间</td>
				<td>订餐电话</td>
				<td>联系人</td>
				<td>是否推荐</td> 
				<td>餐厅图片1</td>
				<td>餐厅图片2</td>
				<td>餐厅图片2</td>
				<td>状态</td>
			</tr>
			<s:iterator value="restaurantDtoList" status="status">
				<tr>
					<td>
						<input type="checkbox" name="sellCheckBox" value="${id}"/>
					</td>
					<td>
						<s:property value="#status.index+1"/>
					</td>
					<td>
						${name }
					</td> 
					<td> 
						${address }
					</td>
					<td>
				
						<%--  
							String mealStyle = getRequest().getParameter("mealStyle");
							System.out.println("mealSytle:"+mealStyle);
						--%>
						<s:if test="mealStyle==1">
							川菜  
						</s:if>
						<s:if test="mealStyle==2">
							湘菜  
						</s:if>
						<s:if test="mealStyle==3">
							粤菜
						</s:if>
					</td>
					<td>
						${beginTime}-${endTime}
					</td>
					<td>
						${moilbe}
					</td>
					<td>
						${linkman}
					</td>
					<td>
						<s:if test="isRecommend == true">
							是
						</s:if>
						<s:else>
							否
						</s:else>
					</td> 
					<td><img src="${webUrl }${images1 }" width="100" height="100"/> </td>
					<td><img src="${webUrl }${images2 }" width="100" height="100"/></td>
					<td><img src="${webUrl }${images3 }" width="100" height="100"/></td>
					<td>
						<s:if test="status == 0">
							审核中
						</s:if>
						<s:if test="status == 1">
							审核通过
						</s:if>
						<s:if test="status == 2">
							审核不通过
						</s:if>
						<s:if test="status == 3">
							作废
						</s:if>
					</td>
				</tr>
			</s:iterator>
		</table>
		<div>
			<jsp:include page="../include/page.jsp"></jsp:include> 
		</div>
	</form>
     
  </body>
</html>
<script type="text/javascript">

	function onsubmitSelect(){
		$("#frmSubmitSelect").submit();//查询提交
	}
</script>